package com.example.controller;

import com.example.service.IRegistrationService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Slf4j
@Api(tags = "挂号模块")
@RequestMapping("/sick")
@RestController
public class RegestrationController {
    public RegestrationController(){
        log.debug("创建挂号请求处理");
    }
    @Autowired
    IRegistrationService service;

    @ApiOperation("添加挂号记录、病人信息")
    @ApiOperationSupport(order = 100)
    @PostMapping("/registration/insert")
    public void registrationInsert(@RequestBody Map<String,Object> data){
        log.debug("开始处理挂号业务参数是{}",data);
        service.registrationInsert(data);
        log.debug("挂号成功");
    }

    @ApiOperation("根据id删除病人")
    @ApiImplicitParam(name = "id", value = "病人id", required = true, dataType = "long")
    @PostMapping("/{id:[0-9a-zA-Z]+}/delete")
    public void deleteById(@PathVariable Long id){
        service.deleteSick(id);
    }

    @ApiOperation("根据id删除挂号信息")
    @ApiImplicitParam(name = "id", value = "挂号信息id", required = true, dataType = "long")
    @PostMapping("/registration/{id:[0-9a-zA-Z]+}/delete")
    public void registrationDelete(@PathVariable Long id){
        service.registrationDeleteById(id);
    }

}
